home *** CD-ROM | disk | FTP | other *** search
Text File | 2000-09-28 | 21.2 KB | 571 lines | [TEXT/MPS ] |
- /*
- File: ShapeUtilitiesGlyphs.c
-
- Contains: QuickDraw GX to PostScript conversion code.
-
- Version: Technology: Quickdraw GX 1.1.x
-
- Copyright: © 1989-1997 by Apple Computer, Inc., all rights reserved.
- */
-
- #undef CHECK_OWNER_COUNT // Check owner counts before disposing
- #undef CREATE_NEW_GLYPH // New glyph shape vs copy and modify original
- #undef NOT_GETPARTS // GetShapeParts vs old way
- #undef OLD_BUCKETS // Use old bucket creation scheme
- #undef SKIA_BUG_2PICTURE // Converting to picture doubles transform (mapping)
-
- #include "GXToPSBuildConfig.h"
- #include <GXGraphics.h>
- #include "GXExceptions.h"
- #include "ShapeUtilities.h"
- #include "IOUtilities.h"
-
-
- /* Chop that glyph! */
- OSErr ShUDissectGlyphs(gxShape theShape, Boolean splitByStyle)
- {
- OSErr status;
- gxShape theSource, thisShape;
- #ifdef NOT_GETPARTS
- #if debugon
- long glyphIndex = 0;
- #endif debugon
-
- short shortOfOne = 1;
- long longOfOne = 1;
- long longAllBitsSet = 0xFFFFFFFF;
- long runLength;
- long textByteCount, theLength, theRuns;
- Ptr theBlock;
- Ptr theText;
- short *theStyleRuns;
- long *theAdvanceBits;
- gxPoint *thePositions, *theTangents;
- gxStyle *theGlyphStyles;
- #ifdef CREATE_NEW_GLYPH
- gxStyle theDefaultStyle;
- gxTransform theDefaultTransform;
- gxInk theDefaultInk;
- #endif CREATE_NEW_GLYPH
- #ifdef OLD_BUCKETS
- short runCount;
- gxTransform identityTransform;
- #endif OLD_BUCKETS
- short advanceArraySize; /* Max size of advance bits array */
- short charCodeSize; /* Size of each character code in text stream */
-
- /* Validate shape type */
- switch (GXGetShapeType(theShape)) {
- case gxTextType:
- /* Check for simple text shape short-cut */
- theLength = GXGetText(theShape, nil, nil, nil);
- nrequire(status = GXGetGraphicsError(nil), failed_GetText);
- if (theLength < 2 || splitByStyle) /* Only has one style run! */
- return(shape_already_in_simple_form);
- GXSetShapeType(theShape, gxGlyphType); /* Convert to glyph */
- break;
- case gxLayoutType:
- /* Check for simple layout shape short-cut */
- theLength = GXGetLayout(theShape, nil, nil, nil, nil, &runCount, nil, nil, nil, nil);
- nrequire(status = GXGetGraphicsError(nil), failed_GetLayout);
- if (theLength < 2 || (splitByStyle && runCount < 2))
- return(shape_already_in_simple_form);
- GXPrimitiveShape(theShape); /* Convert to glyph with layout applied */
- check(GXGetShapeType(theShape) == gxGlyphType);
- break;
- case gxGlyphType:
- break; /* These are great! */
- default:
- status = illegal_type_for_shape; /* Give reason */
- GXPostGraphicsError(status); /* Yell real loud! */
- nrequire(status, failed_WrongShape); /* Bail out */
- }
- nrequire(status = GXGetGraphicsError(nil), failed_ShapeType);
-
- /* Get the sizes */
- textByteCount = GXGetGlyphs(theShape, &theLength, nil, nil, nil, nil, &theRuns, nil, nil);
- nrequire(status = GXGetGraphicsError(nil), failed_GetGlyphs1);
- advanceArraySize = splitByStyle ? (1 + ((theLength - 1) / (8 * sizeof(long)))) : 0; /* Calculate max array size */
-
- /* Check for simple shape short-cut */
- if (theLength < 2 || (splitByStyle && theRuns < 2))
- return(shape_already_in_simple_form);
-
- #ifdef OLD_BUCKETS
- theSource = GXCopyToShape(nil, theShape); /* Make a working copy */
- nrequire(status = GXGetGraphicsError(nil), failed_CopyToShape);
-
- identityTransform = GXNewTransform(); /* Identity transform */
- nrequire(status = GXGetGraphicsError(nil), failed_NewTransform);
- GXSetShapeTransform(theSource, identityTransform); /* Just one mapping, please! */
- GXDisposeTransform(identityTransform); /* Clean up */
- nrequire(status = GXGetGraphicsError(nil), failed_DisposeTransform);
-
- GXSetShapeType(theShape, gxPictureType); /* Create return bucket */
- nrequire(status = GXGetGraphicsError(nil), failed_SetShapeType);
- GXSetPictureParts(theShape, 1, 1, 0, nil, nil, nil, nil); /* Clean it out */
- nrequire(status = GXGetGraphicsError(nil), failed_SetPictureParts);
- #else OLD_BUCKETS
- GXSetShapeType(theShape, gxPictureType); /* Create return bucket */
- nrequire(status = GXGetGraphicsError(nil), failed_SetShapeType);
- GXGetPictureParts(theShape, 1, 1, &thisShape, nil, nil, nil); /* Extract shape */
- nrequire(status = GXGetGraphicsError(nil), failed_GetPictureParts);
-
- theSource = GXCloneShape(thisShape); /* Make a (clone) copy */
- nrequire(status = GXGetGraphicsError(nil), failed_CloneShape);
-
- # ifdef CHECK_OWNER_COUNT
- check(GXGetShapeOwners(thisShape) == 2); /* Pre-SetPictureParts() value */
- # endif CHECK_OWNER_COUNT
- GXSetPictureParts(theShape, 1, 1, 0, nil, nil, nil, nil); /* Clean it out */
- nrequire(status = GXGetGraphicsError(nil), failed_SetPictureParts);
- # ifdef CHECK_OWNER_COUNT
- check(GXGetShapeOwners(theSource) == 1); /* Post-SetPictureParts() value */
- # endif CHECK_OWNER_COUNT
- #endif OLD_BUCKETS
-
- /* Create a block in this form:
- theText = (void *) NewPtr(textByteCount);
- thePositions = (gxPoint *) NewPtr((theLength + 1) * sizeof(gxPoint));
- theAdvanceBits = (long *) NewPtr(advanceArraySize * sizeof(long));
- theTangents = (gxPoint *) NewPtr(theLength * sizeof(gxPoint));
- theStyleRuns = (short *) NewPtr(theRuns * sizeof(short));
- theGlyphStyles = (gxStyle *) NewPtr(theRuns * sizeof(gxStyle));
- */
- status = PrNewPtr(&theBlock
- (textByteCount + /* Text */
- (advanceArraySize * sizeof(long)) + /* Advance bits */
- sizeof(point) + /* Extra entry for thePositions */
- (theLength * (sizeof(gxPoint) + sizeof(gxPoint))) +
- (theRuns * (sizeof(short) + sizeof(gxStyle))))
- );
- nrequire(status, failed_NewPtr);
-
- /* Set the pointers */
- theTangents = (gxPoint *) theBlock;
- thePositions = (gxPoint *) (((Ptr)theTangents) + (theLength * sizeof(gxPoint)));
- theGlyphStyles = (gxStyle *) (((Ptr)thePositions) + ((theLength + 1) * sizeof(gxPoint)));
- theStyleRuns = (short *) (((Ptr)theGlyphStyles) + (theRuns * sizeof(gxStyle)));
- theAdvanceBits = (long *) (((Ptr)theStyleRuns) + (theRuns * sizeof(short)));
- theText = (Ptr) (((Ptr)theAdvanceBits) + (advanceArraySize * sizeof(long)));
-
- /* Check pointer arithmetic (end bytes should match) */
- check((theBlock + GetPtrSize(theBlock)) == (((Ptr)theText) + textByteCount));
-
- GXGetGlyphMetrics(theSource, thePositions, nil, nil); /* Get absolute positions of glyphs */
- nrequire(status = GXGetGraphicsError(nil), failed_GetGlyphMetrics);
-
- GXIgnoreGraphicsNotice(glyph_tangents_have_no_effect); /* Style may already be set */
- GXGetGlyphs(theSource, nil, theText, nil, nil, theTangents, nil, theStyleRuns, theGlyphStyles); /* Get the real meat */
- GXPopGraphicsNotice(); /* Start warning again */
- nrequire(status = GXGetGraphicsError(nil), failed_GetGlyphs2);
-
- charCodeSize = textByteCount / theLength; /* Average character size */
- check((long) charCodeSize * theLength == textByteCount); /* Only accurate for consistent size platform styles */
-
- #ifdef CREATE_NEW_GLYPH
- /* Get shape defaults */
- theDefaultStyle = GXGetShapeStyle(theSource);
- theDefaultTransform = GXGetShapeTransform(theSource);
- theDefaultInk = GXGetShapeInk(theSource);
- #endif CREATE_NEW_GLYPH
-
- if (splitByStyle) { /* Split each style run into separate picture element */
- for ( ; --advanceArraySize >= 0 ; ) /* Initialize max array */
- theAdvanceBits[advanceArraySize] = longAllBitsSet;
- for ( ; --theRuns >= 0 ; ) { /* Loop through run styles */
- runLength = *theStyleRuns; /* Needs to pass a (long *) */
- #ifdef CREATE_NEW_GLYPH
- thisShape = GXNewGlyphs(runLength, theText, thePositions, theAdvanceBits, theTangents, theStyleRuns++, theGlyphStyles++); /* Make new one */
- nrequire(status = GXGetGraphicsError(nil), failed_NewGlyphs2);
- GXIgnoreGraphicsNotice(style_already_set); /* Style may already be set */
- GXSetShapeStyle(thisShape, theDefaultStyle);
- GXPopGraphicsNotice(); /* Start warning again */
- GXIgnoreGraphicsNotice(transform_already_set); /* Transform may already be set */
- GXSetShapeTransform(thisShape, theDefaultTransform);
- GXPopGraphicsNotice(); /* Start warning again */
- GXIgnoreGraphicsNotice(ink_already_set); /* Ink may already be set */
- GXSetShapeInk(thisShape, theDefaultInk);
- GXPopGraphicsNotice(); /* Start warning again */
- nrequire(status = GXGetGraphicsError(nil), failed_SetShapeDefaults2);
- #else CREATE_NEW_GLYPH
- thisShape = GXCopyToShape(nil, theSource); /* To insure proper default style, transform, and ink */
- nrequire(status = GXGetGraphicsError(nil), failed_NewGlyphs2);
- GXSetGlyphs(thisShape, runLength, theText, thePositions, theAdvanceBits, theTangents, theStyleRuns++, theGlyphStyles++); /* Override glyph */
- nrequire(status = GXGetGraphicsError(nil), failed_SetGlyphs2);
- #endif CREATE_NEW_GLYPH
- #ifdef CHECK_OWNER_COUNT
- check(GXGetShapeOwners(thisShape) == 1); /* Pre-SetPictureParts() value */
- #endif CHECK_OWNER_COUNT
- GXSetPictureParts(theShape, 0, 0, 1, &thisShape, nil, nil, nil); /* Append the part */
- nrequire(status = GXGetGraphicsError(nil), failed_AddToPicture2);
- #ifdef CHECK_OWNER_COUNT
- check(GXGetShapeOwners(thisShape) == 2); /* Post-SetPictureParts() value */
- #endif CHECK_OWNER_COUNT
- GXDisposeShape(thisShape); /* Don't litter! */
- theText += ((short) runLength * charCodeSize); /* Advance to next byte (DEPENDS on PLATFORM!) */
- thePositions += runLength; /* Advance positions */
- theTangents += runLength; /* Advance tangents */
- #if debugon
- glyphIndex += runLength; /* Increase glyph count */
- #endif debugon
- }
- }
- else { /* Split each glyph into separate picture element */
- for ( ; --theRuns >= 0 ; ) { /* Loop through run styles */
- for (runCount = *(theStyleRuns++) - 1; runCount >= 0; --runCount) { /* Repeat for the run */
- #ifdef CREATE_NEW_GLYPH
- thisShape = GXNewGlyphs(longOfOne, theText, thePositions++, &longAllBitsSet, theTangents++, &shortOfOne, theGlyphStyles); /* Make new one */
- nrequire(status = GXGetGraphicsError(nil), failed_NewGlyphs);
- GXIgnoreGraphicsNotice(style_already_set); /* Style may already be set */
- GXSetShapeStyle(thisShape, theDefaultStyle);
- GXPopGraphicsNotice(); /* Start warning again */
- GXIgnoreGraphicsNotice(transform_already_set); /* Transform may already be set */
- GXSetShapeTransform(thisShape, theDefaultTransform);
- GXPopGraphicsNotice(); /* Start warning again */
- GXIgnoreGraphicsNotice(ink_already_set); /* Ink may already be set */
- GXSetShapeInk(thisShape, theDefaultInk);
- GXPopGraphicsNotice(); /* Start warning again */
- nrequire(status = GXGetGraphicsError(nil), failed_SetShapeDefaults);
- #else CREATE_NEW_GLYPH
- thisShape = GXCopyToShape(nil, theSource); /* To insure proper default style, transform, and ink */
- nrequire(status = GXGetGraphicsError(nil), failed_NewGlyphs);
- GXSetGlyphs(thisShape, longOfOne, theText, thePositions++, &longAllBitsSet, theTangents++, &shortOfOne, theGlyphStyles); /* Override glyph */
- nrequire(status = GXGetGraphicsError(nil), failed_SetGlyphs);
- #endif CREATE_NEW_GLYPH
- #ifdef CHECK_OWNER_COUNT
- check(GXGetShapeOwners(thisShape) == 1); /* Pre-SetPictureParts() value */
- #endif CHECK_OWNER_COUNT
- GXSetPictureParts(theShape, 0, 0, 1, &thisShape, nil, nil, nil); /* Append the part */
- nrequire(status = GXGetGraphicsError(nil), failed_AddToPicture);
- #ifdef CHECK_OWNER_COUNT
- check(GXGetShapeOwners(thisShape) == 2); /* Post-SetPictureParts() value */
- #endif CHECK_OWNER_COUNT
- GXDisposeShape(thisShape); /* Don't litter! */
- theText += charCodeSize; /* Advance to next byte (DEPENDS on PLATFORM!) */
- #if debugon
- ++glyphIndex; /* Next glyph */
- #endif debugon
- }
- ++theGlyphStyles; /* Next style in run */
- }
- }
-
- check(glyphIndex == theLength); /* Correct number of glyphs? */
- check((theBlock + GetPtrSize(theBlock)) == ((Ptr)theText)); /* Correct text length? */
-
- (void) PrDisposePtr(theBlock); /* Don't litter! */
- #ifdef CHECK_OWNER_COUNT
- check(GXGetShapeOwners(theSource) == 1); /* Disposing last reference */
- #endif CHECK_OWNER_COUNT
- GXDisposeShape(theSource); /* Don't litter! */
- return(noErr); /* OK */
-
- /* BAILOUTS */
- failed_AddToPicture2:
- failed_AddToPicture:
- failed_SetShapeDefaults2:
- failed_SetShapeDefaults:
- failed_NewGlyphs2:
- failed_NewGlyphs:
- failed_SetGlyphs2:
- failed_SetGlyphs:
- failed_GetGlyphs2:
- failed_GetGlyphMetrics:
- (void) PrDisposePtr(theBlock); /* Don't litter! */
- failed_NewPtr:
- failed_SetPictureParts:
- failed_DisposeTransform:
- failed_NewTransform:
- DisposeShape(theSource); /* Don't litter! */
- failed_CopyToShape:
- failed_CloneShape:
- failed_GetPictureParts:
- failed_SetShapeType:
- failed_GetGlyphs1:
- failed_ShapeType:
- failed_WrongShape:
- failed_GetLayout:
- failed_GetText:
-
- #else NOT_GETPARTS
- long glyphIndex = 1;
- long runLength;
- long textByteCount, theLength, theRuns;
- Ptr theBlock = NULL;
- short *theStyleRuns;
- #ifdef OLD_BUCKETS
- transform identityTransform;
- #endif OLD_BUCKETS
-
- /* Validate shape type and get the sizes */
- switch (GXGetShapeType(theShape)) {
- case gxTextType:
- GXGetText(theShape, &theLength, nil, nil);
- theRuns = 1; /* Text has only one style */
- break;
- case gxLayoutType:
- GXSetShapeAttributes(theShape, GXGetShapeAttributes(theShape) + gxNoMetricsGridShape);
- GXPrimitiveShape(theShape); // convert it to a glyph shape.
- check(GXGetShapeType(theShape) == gxGlyphType);
- /** Fall through to glyph case **/
- case gxGlyphType:
- textByteCount = GXGetGlyphs(theShape, &theLength, nil, nil, nil, nil, &theRuns, nil, nil);
- break; /* These are great! */
- default:
- status = illegal_type_for_shape; /* Give reason */
- GXPostGraphicsError(status); /* Yell real loud! */
- nrequire(status, failed_WrongShape); /* Bail out */
- }
- nrequire(status = GXGetGraphicsError(nil), failed_ShapeType);
-
- /* Check for simple shape short-cut */
- if (theLength < 2 || (splitByStyle && theRuns < 2))
- return(shape_already_in_simple_form);
-
- #ifdef OLD_BUCKETS
- theSource = GXCopyToShape(nil, theShape); /* Make a working copy */
- nrequire(status = GXGetGraphicsError(nil), failed_CopyToShape);
-
- identityTransform = GXNewTransform(); /* Identity transform */
- nrequire(status = GXGetGraphicsError(nil), failed_NewTransform);
- GXSetShapeTransform(theSource, identityTransform); /* Just one mapping, please! */
- GXDisposeTransform(identityTransform); /* Clean up */
- nrequire(status = GXGetGraphicsError(nil), failed_DisposeTransform);
-
- GXSetShapeType(theShape, gxPictureType); /* Create return bucket */
- nrequire(status = GXGetGraphicsError(nil), failed_SetShapeType);
- GXSetPictureParts(theShape, 1, 1, 0, nil, nil, nil, nil); /* Clean it out */
- nrequire(status = GXGetGraphicsError(nil), failed_SetPictureParts);
- #else OLD_BUCKETS
- GXSetShapeType(theShape, gxPictureType); /* Create return bucket */
- nrequire(status = GXGetGraphicsError(nil), failed_SetShapeType);
- GXGetPictureParts(theShape, 1, 1, &thisShape, nil, nil, nil); /* Extract shape */
- nrequire(status = GXGetGraphicsError(nil), failed_GetPictureParts);
-
- theSource = GXCloneShape(thisShape); /* Make a (clone) copy */
- nrequire(status = GXGetGraphicsError(nil), failed_CloneShape);
-
- #ifdef REMOVE
- // gx graphics used to double-transform picture shapes -- we fixed
- // this in gx graphics on 1/19/94
- {
- gxTransform identityTransform;
-
- identityTransform = GXNewTransform(); /* Identity transform */
- nrequire(status = GXGetGraphicsError(nil), failed_NewTransform);
- GXSetShapeTransform(theSource, identityTransform); /* Just one mapping, please! */
- GXDisposeTransform(identityTransform); /* Clean up */
- nrequire(status = GXGetGraphicsError(nil), failed_DisposeTransform);
- }
- #endif
-
- # ifdef CHECK_OWNER_COUNT
- check(GXGetShapeOwners(thisShape) == 2); /* Pre-SetPictureParts() value */
- # endif CHECK_OWNER_COUNT
- GXSetPictureParts(theShape, 1, 1, 0, nil, nil, nil, nil); /* Clean it out */
- nrequire(status = GXGetGraphicsError(nil), failed_SetPictureParts);
- # ifdef CHECK_OWNER_COUNT
- check(GXGetShapeOwners(theSource) == 1); /* Post-SetPictureParts() value */
- # endif CHECK_OWNER_COUNT
- #endif OLD_BUCKETS
-
- if (splitByStyle) { /* Split each style run into separate picture element */
- status = PrNewPtr(&theBlock, (theRuns * sizeof(short)));
- theStyleRuns = (short *) theBlock;
- nrequire(status, failed_NewPtr);
-
- GXGetGlyphs(theSource, nil, nil, nil, nil, nil, nil, theStyleRuns, nil); /* Get the real meat */
- nrequire(status = GXGetGraphicsError(nil), failed_GetGlyphs2);
-
- for ( ; --theRuns >= 0 ; ) { /* Loop through run styles */
- runLength = *(theStyleRuns++); /* Needs to pass a (long *) */
-
- check (runLength > 0); /* Is this test needed? */
- if (runLength > 0) {
- thisShape = GXGetShapeParts(theSource, glyphIndex, runLength, nil);
- nrequire(status = GXGetGraphicsError(nil), failed_GetShapeParts2);
-
- #ifdef CHECK_OWNER_COUNT
- check(GXGetShapeOwners(thisShape) == 1); /* Pre-SetPictureParts() value */
- #endif CHECK_OWNER_COUNT
- GXSetPictureParts(theShape, 0, 0, 1, &thisShape, nil, nil, nil); /* Append the part */
- nrequire(status = GXGetGraphicsError(nil), failed_AddToPicture2);
- #ifdef CHECK_OWNER_COUNT
- check(GXGetShapeOwners(thisShape) == 2); /* Post-SetPictureParts() value */
- #endif CHECK_OWNER_COUNT
-
- GXDisposeShape(thisShape); /* Don't litter! */
-
- glyphIndex += runLength; /* Increase glyph count */
- }
- }
- check (theStyleRuns = &((short *) theBlock)[theRuns]);
- DisposePtr(theBlock); /* Don't litter! */
- theBlock = NULL;
- }
- else { /* Split each glyph into separate picture element */
- for (; glyphIndex <= theLength; ) { /* Loop through glyphs */
- thisShape = GXGetShapeParts(theSource, glyphIndex++, 1, nil);
- nrequire(status = GXGetGraphicsError(nil), failed_GetShapeParts);
-
- #ifdef CHECK_OWNER_COUNT
- check(GXGetShapeOwners(thisShape) == 1); /* Pre-SetPictureParts() value */
- #endif CHECK_OWNER_COUNT
- GXSetPictureParts(theShape, 0, 0, 1, &thisShape, nil, nil, nil); /* Append the part */
- nrequire(status = GXGetGraphicsError(nil), failed_AddToPicture);
- #ifdef CHECK_OWNER_COUNT
- check(GXGetShapeOwners(thisShape) == 2); /* Post-SetPictureParts() value */
- #endif CHECK_OWNER_COUNT
-
- GXDisposeShape(thisShape); /* Don't litter! */
- }
- }
-
- check((glyphIndex - 1) == theLength); /* Correct number of glyphs? */
-
- #ifdef CHECK_OWNER_COUNT
- check(GXGetShapeOwners(theSource) == 1); /* Disposing last reference */
- #endif CHECK_OWNER_COUNT
- GXDisposeShape(theSource); /* Don't litter! */
-
- return(noErr); /* OK */
-
-
- /* BAILOUTS */
- failed_AddToPicture2:
- failed_AddToPicture:
- failed_GetShapeParts2:
- failed_GetShapeParts:
- failed_GetGlyphs2:
- if (theBlock)
- DisposePtr(theBlock); /* Don't litter! */
-
- failed_NewPtr:
- failed_SetPictureParts:
- failed_DisposeTransform:
- failed_NewTransform:
- GXDisposeShape(theSource); /* Don't litter! */
- failed_CopyToShape:
- failed_CloneShape:
- failed_GetPictureParts:
- failed_SetShapeType:
- failed_ShapeType:
- failed_WrongShape:
- #endif NOT_GETPARTS
-
- return(status); /* Propagate error */
- }
-
-
-
-
-
- /***************************************************
-
- Function: TextToUnhintedPath
-
- Function converts a text/layout/glyph shape into
- an unhinted path with ideal metrics.
-
- All styles that need to be modified are copied so any shared
- references aren't affected.
-
- ****************************************************/
- OSErr TextToUnhintedPath(gxShape target)
- {
- OSErr status = noErr;
- gxShapeType theType;
- gxStyle aStyle;
- gxStyle *styles, *pStyle;
- gxTextAttribute *oldAttributes, *pAttributes, oldMainAttributes;
- long nStyles, i, charCount;
-
- theType = GXGetShapeType(target);
-
- // Make sure metrics are unhinted for shape's main style.
-
- aStyle = GXGetShapeStyle(target);
- oldMainAttributes = GXGetStyleTextAttributes( aStyle );
- GXSetStyleTextAttributes(aStyle, oldMainAttributes | gxNoContourGridText | gxNoMetricsGridText );
-
- switch(theType) {
-
- case gxTextType:
- GXSetShapeType(target, gxPathType);
- break;
-
- case gxLayoutType:
- GXPrimitiveShape(target); // try to convert it to a glyph shape
- theType = GXGetShapeType(target); // if there were no glyphs, it will be empty.
- if (theType == gxEmptyType) // so we fall out.
- break;
-
- // otherwise fall through to glyph case (assuming it is glyph)
-
- case gxGlyphType:
- // Get memory for the styles and the style's text attributes
- GXGetGlyphs(target, &charCount, nil, nil, nil, nil, &nStyles, nil, nil);
- nrequire(status = GXGetGraphicsError(nil), failed_GetGlyphs);
-
- status = PrNewPtr((Ptr *) &styles, nStyles * (sizeof(gxStyle) + sizeof(gxTextAttribute)) );
- nrequire(status, failed_newptr);
-
- oldAttributes = (gxTextAttribute*) ( (Ptr)styles + nStyles * sizeof(gxStyle) );
-
- GXGetGlyphs(target, nil, nil, nil, nil, nil, nil, nil, styles);
- nrequire(status = GXGetGraphicsError(nil), failed_GetGlyphs1);
-
- /* Turn off hinting for all styles in shape */
-
- pStyle = styles;
- pAttributes = oldAttributes;
- for (i = 0; i < nStyles; ++i, ++pStyle, ++pAttributes) {
-
- if (*pStyle != nil) {
-
- *pAttributes = GXGetStyleTextAttributes(*pStyle);
- GXSetStyleTextAttributes(*pStyle, *pAttributes | gxNoContourGridText | gxNoMetricsGridText );
-
- }//end if
-
- }//end for
-
- // Now, Convert it to a path.
-
- GXSetShapeType( target, gxPathType );
- nrequire(status = GXGetGraphicsError(nil), failed_changeType);
-
-
- // Now restore the old attributes
-
- pStyle = styles;
- pAttributes = oldAttributes;
- for (i = 0; i < nStyles; ++i, ++pStyle, ++pAttributes)
- if (*pStyle != nil)
- GXSetStyleTextAttributes(*pStyle, *pAttributes);
-
- GXSetStyleTextAttributes(aStyle, oldMainAttributes);
-
- failed_changeType:
- // We're done, clean up .
-
- failed_GetGlyphs1:
- DisposePtr((Ptr)styles);
-
- break;
-
- default:
- break;
-
- }//end switch (theType);
-
- failed_newptr:
- failed_GetGlyphs:
-
- return(status);
-
- }//TextToUnhintedPath
-
-
-